<html>
<head><meta charset="utf-8"><title>specialization: exclude traits or types · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/specialization.3A.20exclude.20traits.20or.20types.html">specialization: exclude traits or types</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="229141547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/specialization%3A%20exclude%20traits%20or%20types/near/229141547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremiah Senkpiel <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/specialization.3A.20exclude.20traits.20or.20types.html#229141547">(Mar 07 2021 at 00:27)</a>:</h4>
<p>I haven't been able to find much information for discussion on this. What I mean is something like the following:</p>
<ul>
<li><code>impl&lt;T: traitA + !traitB&gt; From&lt;T&gt; for Type</code></li>
<li><code>impl&lt;T: traitA + !Self&gt; From&lt;T&gt; for Type</code><br>
I.e.</li>
</ul>



<a name="229141646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/specialization%3A%20exclude%20traits%20or%20types/near/229141646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremiah Senkpiel <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/specialization.3A.20exclude.20traits.20or.20types.html#229141646">(Mar 07 2021 at 00:28)</a>:</h4>
<p>Where <code>!traitB</code> makes <code>T</code> exclude types which are <code>traitB</code>, and where <code>!Self</code> excludes <code>Self</code> (<code>Type</code>) if <code>Type</code> also implements <code>traitA</code>.</p>



<a name="229141767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/specialization%3A%20exclude%20traits%20or%20types/near/229141767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremiah Senkpiel <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/specialization.3A.20exclude.20traits.20or.20types.html#229141767">(Mar 07 2021 at 00:30)</a>:</h4>
<p>I think this could be reduced to the <code>Self</code> case either entirely or as a first step, if needed. It would be extremely handy to be able to exclude self from <code>From</code>/<code>Into</code> impls where the trait bounds you are doing this on are also implemented by your type.</p>



<a name="229141793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/specialization%3A%20exclude%20traits%20or%20types/near/229141793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Rothstein <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/specialization.3A.20exclude.20traits.20or.20types.html#229141793">(Mar 07 2021 at 00:31)</a>:</h4>
<p>probably not the person you were hoping to reply, but i think that's <a href="https://github.com/rust-lang/rfcs/pull/586">https://github.com/rust-lang/rfcs/pull/586</a> (in particular <a href="https://github.com/kennytm/rfcs/blob/neg-bounds/text/0000-negative-bounds.md#negative-bounds">https://github.com/kennytm/rfcs/blob/neg-bounds/text/0000-negative-bounds.md#negative-bounds</a>)</p>



<a name="229141836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/specialization%3A%20exclude%20traits%20or%20types/near/229141836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremiah Senkpiel <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/specialization.3A.20exclude.20traits.20or.20types.html#229141836">(Mar 07 2021 at 00:32)</a>:</h4>
<p>In particular, this would solve the <code>std::error::Error</code> issue for dyn error types like <code>anyhow::Error</code>, <code>eyre::Error</code>, <code>http_types::Error</code>, etc.</p>



<a name="229141863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/specialization%3A%20exclude%20traits%20or%20types/near/229141863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremiah Senkpiel <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/specialization.3A.20exclude.20traits.20or.20types.html#229141863">(Mar 07 2021 at 00:32)</a>:</h4>
<p>My understanding of negative impls were they they were not this but rather something else, maybe I am mistaken though.</p>



<a name="229141997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/specialization%3A%20exclude%20traits%20or%20types/near/229141997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremiah Senkpiel <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/specialization.3A.20exclude.20traits.20or.20types.html#229141997">(Mar 07 2021 at 00:34)</a>:</h4>
<p>That RFC also does not specifically mention the self case, but I think the self case is the most compelling since it solves a handful of other issues directly without needing full specialization.</p>



<a name="229142005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/specialization%3A%20exclude%20traits%20or%20types/near/229142005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremiah Senkpiel <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/specialization.3A.20exclude.20traits.20or.20types.html#229142005">(Mar 07 2021 at 00:34)</a>:</h4>
<p>(Or <em>could</em> solve.)</p>



<a name="229143681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/specialization%3A%20exclude%20traits%20or%20types/near/229143681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremiah Senkpiel <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/specialization.3A.20exclude.20traits.20or.20types.html#229143681">(Mar 07 2021 at 01:03)</a>:</h4>
<p>Also, related issue: <a href="https://github.com/rust-lang/project-error-handling/issues/30">https://github.com/rust-lang/project-error-handling/issues/30</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>